/**
 * 取得通过静态页面传递过来的参数
 * @auth xue
 * @param name 参数名称
 * @returns 参数值
 */
function getURLPara(name) {
	return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
};

function  tips (tip){//公用弹窗提示
	layer.open({
		content: tip
		,skin: 'msg'
		,time: 2 //2秒后自动关闭
	});
};

function sendRequest (urls,params,successFunc){//公用ajax请求weixin
	layer.open({
		type: 2
		,content: ''
		,time: 0.4
	});
	$.ajax({
		type: "post",
		contentType: 'application/json;charset=utf-8',
		dataType:'json',
		url:url+urls,
		data:JSON.stringify(params),
		cache:false,
		async:true,
		//dataType: 'json',
		success: successFunc
	});

};
function sendRequestPms (urls,params,successFunc){//公用ajax请求Pms
	layer.open({
		type: 2
		,content: ''
		,time: 0.3
	});
	$.ajax({
		type: "post",
		contentType: 'application/json;charset=utf-8',
		dataType:'json',
		url:pmsUrl+urls,
		data:JSON.stringify(params),
		cache:false,
		async:true,
		//dataType: 'json',
		success: successFunc
	});
};

function sendRequestAsy (urls,params,successFunc){//公用ajax请求:同步
	$.ajax({
		type: "post",
		contentType: 'application/json;charset=utf-8',
		dataType:'json',
		url:url+urls,
		data:JSON.stringify(params),
		cache:false,
		async:false,
		//dataType: 'json',
		success: successFunc
	});
};

function goLogin(res){//公用回家方法
	var that=this;
	if(res.returnCode=="yuju-1022"){
		//alert('这里跳转到登录页')
		var  opId = _lSGet('opId');
		if(opId==null||opId==''||opId==undefined){
			window.location.href=backUrl;
		}else{
			var params = {};
			params.id = opId;
			sendRequestAsy('/wxLogin/quietLogin', params, function(res) {//登录
				if(res.status==1){
					_lSSaveOrUpdate( 'token', res.data.opInfo.token );
					_lSSaveOrUpdate( 'openId', res.data.opInfo.openId );
					_lSSaveOrUpdate( 'userId', res.data.opInfo.userId );
					_lSSaveOrUpdate( 'levelName', res.data.opInfo.levelName );//会员等级
					_lSSaveOrUpdate( 'userName', res.data.opInfo.userName );//会员名
					_lSSaveOrUpdate( 'userName', res.data.opInfo.userName );
					_lSSaveOrUpdate( 'urls', JSON.stringify(res.data.urls) );
					window.location.reload();
					var  forwordPage = _lSGet('forwordPage');
					window.location.href = indexUrl + forwordPage + '?_t=' + Math.random();
				}

			});
		}


	}
};
function fmtDate(obj){//封装时间戳转时间方法
	var date =  new Date(obj);
	var y = 1900+date.getYear();
	var m = "0"+(date.getMonth()+1);
	var d = "0"+date.getDate();
	return y+"-"+m.substring(m.length-2,m.length)+"-"+d.substring(d.length-2,d.length);
};
